let obj = { "name1": "张三", "name2": "李四" };


let key3 = "name1"
console.log(obj.name1)  //张三
// console.log(obj."name1")  //报错
console.log(obj.key3)  //undefined   。后面不是变量
console.log(obj['name2'])  //李四
console.log(obj[key3])  //张三
console.log(obj[name1])  //name1 is not defined
 
let obj1 = { name1: "张三", name2: "李四" };

console.log(obj1.name1)  //张三
console.log(obj1.key3)  //undefined   。后面不是变量
console.log(obj1['name2'])  //李四
console.log(obj1[key3])  //张三
console.log(obj[name1])  //name1 is not defined


